<template>
  <div class="steps" :class="{ margin: !revise }">
    <h3 class="edit-title" v-if="revise">
      <i>{{
        editTitle == "basicinfo"
          ? "修改基本信息"
          : editTitle == "signup"
          ? "修改佐证资料"
          : "修改报名信息"
      }}</i>
    </h3>
    <template v-else>
      <div
        class="step"
        :class="{
          active: step == '1',
          over: step != '1',
          pointer: stuList.step == 1 || stuList.step == 2,
          step1: step == '1',
        }"
        @click="goStep('1')"
      >
        <span class="step-icon">1</span>
        <span class="step-text">基本信息</span>
      </div>
      <div
        class="step"
        :class="{
          active: step == '2',
          over: step == '3',
          pointer: stuList.step == 2,
          step2: step == '2',
          lineafter: step == '1',
          linebefore: step == '3',
        }"
        @click="goStep('2')"
      >
        <span class="step-line"></span>
        <span class="step-icon">2</span>
        <span class="step-text">佐证资料</span>
      </div>
      <div class="step" :class="{ active: step == '3', step3: step == '3' }">
        <span class="step-line"></span>
        <span class="step-icon">3</span>
        <span class="step-text">在线报名</span>
      </div>
    </template>
  </div>
</template>

<script>
export default {
  name: "Steps",
  props: {
    step: {
      type: Number,
      default: 1,
    },
    revise: {
      type: Boolean,
      default: false,
    },
    editTitle: {
      type: String,
    },
  },
  data() {
    return {};
  },
  computed: {
    stuList() {
      return this.$store.state.stuList;
    },
  },
  methods: {
    goStep(step) {
      if (step == "1") {
        this.$router.push({ path: "/basicinfo" });
      } else if (step == "2") {
        // if (this.stuList.step == 2) {
        //   this.$router.push({ path: "/signup" });
        // }
        if (this.step == "3") {
          this.$router.push({ path: "/signup" });
        }
      }
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.margin {
  margin: 0 0 20px;
}
.steps {
  height: 46px;
  background-color: #fff;
  font-size: 0;
  border-radius: 4px;
  box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.06);
  .step {
    display: inline-block;
    line-height: 46px;
    text-align: center;
    cursor: pointer;
    .step-icon {
      display: inline-block;
      margin-top: 9px;
      width: 28px;
      height: 28px;
      margin-right: 10px;
      line-height: 28px;
      border: 1px #333333 solid;
      border-radius: 50%;
      font-size: 16px;
      color: #222;
    }
    .step-text {
      line-height: 46px;
      display: inline-block;
      // margin-right: 38px;
      color: #222;
      font-size: 16px;
      font-family: MicrosoftYaHei;
    }

    &.active {
      .step-icon {
        color: #fff;
        background-color: rgba($color: #fff, $alpha: 0);
        border-color: #fff;
      }
      .step-text {
        color: #fff;
      }
      &::after {
        display: none;
      }
    }
    &.over {
      .step-icon {
        margin-top: -10px;
        // color: $bsC;
        background: url(~@/assets/images/steps_active.png) no-repeat;
        border: none;
        font-size: 0;
        vertical-align: middle;
      }
      .step-text {
        color: $bsC;
      }
      &::after {
        display: block;
      }
    }
    &.pointer {
      cursor: pointer;
    }
    &:nth-child(1) {
      width: 404px;
      height: 100%;
    }
    &:nth-child(2) {
      width: 407px;
      height: 100%;
      margin-left: -10px;
      position: relative;
    }
    &:nth-child(3) {
      width: 389px;
      height: 100%;
      margin-left: 10px;
      &::after {
        display: none;
      }
    }
    &.linebefore {
      &::before {
        content: "";
        width: 31px;
        height: 31px;
        border: 1px solid;
        position: absolute;
        top: 5.5px;
        left: 0px;
        border-top-right-radius: 8px;
        transform: rotate(45deg);
        border-color: #d3ecfe #d3ecfe transparent transparent;
      }
    }
    &.lineafter {
      &::after {
        content: "";
        width: 31px;
        height: 31px;
        border: 1px solid;
        position: absolute;
        top: 6.5px;
        right: 0px;
        border-top-right-radius: 8px;
        transform: rotate(45deg);
        border-color: #eeeeee #eeeeee transparent transparent;
      }
    }
  }
  .step1 {
    background: url(~@/assets/images/steps_base.png) no-repeat;
  }
  .step2 {
    background: url(~@/assets/images/steps_info.png) no-repeat;
  }
  .step3 {
    background: url(~@/assets/images/steps_online.png) no-repeat;
    .step-text {
      margin-right: 0;
    }
  }
  .edit-title {
    line-height: 43px;
    height: 46px;
    color: #fff;
    font-size: 20px;
    text-align: center;
    border-radius: 4px;
    background: url(~@/assets/images/bg_edit.png) no-repeat center;
    i {
      position: relative;
      display: inline-block;
      &::before {
        position: absolute;
        top: 14px;
        left: -25px;
        content: "";
        width: 16px;
        height: 16px;
        // background: url(~@/assets/images/icon_l.png) no-repeat;
        background: url(~@/assets/images/pic_btzs.png) no-repeat center/cover;
      }
      &::after {
        position: absolute;
        top: 14px;
        right: -25px;
        content: "";
        width: 16px;
        height: 16px;
        background: url(~@/assets/images/pic_btzs.png) no-repeat center/cover;
      }
    }
  }
}
</style>
